ci: run E2E suites in demo apps (Android) - #381
Conversation
# Conflicts: # .github/actions/androidapp-road-test/action.yml # apps/AndroidApp/app/build.gradle.kts # apps/AndroidApp/app/src/main/java/com/callstack/brownfield/android/example/MainActivity.kt # apps/brownfield-example-shared-tests/e2e/detoxUtils.cjs # apps/brownfield-example-shared-tests/e2e/e2eTestIds.cjs
| class BrownfieldApplication : Application(), ReactApplication { | ||
| @Suppress("DEPRECATION") | ||
| override val reactNativeHost: ReactNativeHost | ||
| get() = ReactNativeHostManager.reactNativeHost |
There was a problem hiding this comment.
I believe you need to declare reactNativeHost only because of Expo54 as it contains the deprecated API usage.
If yes, then we can hold this PR until we remove Expo54, which will be done soon after #360
The reason I am suggesting to hold this PR is because we are shipping deprecated stuff as part of Expo config plugin for apps above SDK 54 and they do not require it.
There was a problem hiding this comment.
So the reactNativeHost override in BrownfieldApplication is effectively required for Expo 54 Detox; for Expo 55 and vanilla, reactHost is sufficient and matches RN’s direction (same as Detox #4895 around New Architecture).
Config plugin vs test app:
The deprecated pre55 template (ReactNativeHostWrapper, etc.) is only generated for Expo < 55 — not for SDK 55+ consumers.
BrownfieldApplication lives in the example AndroidApp, not in the published library API.
On holding until #360: Reasonable if the goal is zero deprecated surface before merge. Counter-arguments for merging now:
Android E2E targets Vanilla + Expo 55; Expo 54 is road-test only (no E2E).
We could drop the reactNativeHost override from shared BrownfieldApplication and move it to an expo54 flavor-specific source set once #360 lands, leaving reactHost only for 55+.
Proposed path: Merge E2E for 55/vanilla now, or gate on #360 — your call. If we proceed, a follow-up to flavor-split BrownfieldApplication (expo54 vs 55+) would address the deprecated API concern without blocking E2E.
There was a problem hiding this comment.
Thanks for the response, appreciate it. I would prefer to hold this PR until end of this week, in the meantime, we will get SDK 56 support merged and SDK 54 apps removal. Then we can rebase this PR and get rid of deprecated API stuff and get it merged.
There was a problem hiding this comment.
Sounds good to me thanks!
There was a problem hiding this comment.
@alpharius-ck - Since we only have SDK 56 and 57 supported, we can remove this deprecated API stuff.
…roid/example/BrownfieldApplication.kt Co-authored-by: Hur Ali <hurali97@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@hurali97 @artus9033 ready for the final review |
|
CC @hurali97 - would you review? |
| val reactHost = ReactNativeBrownfield.shared.reactHost | ||
| reactHost.currentReactContext?.let { | ||
| Toast.makeText(this, "React Native has been loaded", Toast.LENGTH_LONG).show() | ||
| return | ||
| } | ||
|
|
||
| reactHost.addReactInstanceEventListener(object : ReactInstanceEventListener { | ||
| override fun onReactContextInitialized(context: ReactContext) { | ||
| Toast.makeText( | ||
| this@MainActivity, | ||
| "React Native has been loaded", | ||
| Toast.LENGTH_LONG | ||
| ).show() | ||
| reactHost.removeReactInstanceEventListener(this) | ||
| } | ||
| }) | ||
| } |
There was a problem hiding this comment.
Q: Why do we need to reinvent this block? Why we cant use the following removed block?
ReactNativeHostManager.initialize(application) {
Toast.makeText(
this,
"React Native has been loaded",
Toast.LENGTH_LONG
).show()
}| import com.facebook.react.ReactNativeHost | ||
|
|
||
| object ReactNativeHostManager { | ||
| @Suppress("DEPRECATION") | ||
| val reactNativeHost: ReactNativeHost | ||
| get() = | ||
| throw RuntimeException( | ||
| "You should not use ReactNativeHost directly in the New Architecture" | ||
| ) | ||
|
|
There was a problem hiding this comment.
I believe if you remove the deprecation related code usage from Android App you wont need to make this change._
| @Suppress("DEPRECATION") | ||
| val reactNativeHost: ReactNativeHost | ||
| get() = | ||
| throw RuntimeException( | ||
| "You should not use ReactNativeHost directly in the New Architecture" | ||
| ) |
Summary
Adds and stabilizes Android Detox E2E for the brownfield demo apps (AndroidApp + embedded RN hosts), covering vanilla, Expo 56, and Expo 57.
CI pipeline
E2E reliability (Expo on Android)
Headless CI emulators often break Espresso/Detox sync and clipped NativeTabs taps. This PR hardens shared helpers around: